package servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import pojo.School;
import pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Authther: mrwu
 * @date:2021/3/12-03
 * @Description:servlet
 */
@WebServlet("/user")
public class Userservlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        School school = new School("xiaoxue","wujiagou");
        User user = new User(1L,"huisheng",school);
        ObjectMapper mapper = new ObjectMapper();
        String value = mapper.writeValueAsString(user);
        resp.getWriter().write(value);
        resp.getWriter().flush();
    }
}
